function qs(ele) {
    return document.querySelector(ele)
}
axios.defaults.baseURL = 'http://124.223.14.236:3001/api'

//手机号码验证部分
let reg = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/

console.log('999')
//登录密码验证部分
let reg1 = /^[a-zA-Z]\w{5,17}$/

//点击登录按钮发起请求
qs('#js-btn-login').addEventListener('click',async function (e) {
    e.preventDefault()
    // console.log(qs('#username').value)
    // if(!reg.test(qs('#username').value)) {
    //     return alert('请输入正确手机号')
    // }
    if (!reg1.test(qs('#password').value)) {
        return alert('请输入正确密码')
    }
    const res = await axios({
        method: 'POST',
        url: '/user/login',
        data: {
            username: qs('#username').value,
            password: qs('#password').value
        }
    })
    console.log(res)
})


//跳转注册界面
qs('#reg').addEventListener('click', function () {
    location.href = '/02-regbaseCode/reg.html'
})